#include <iostream>
using namespace std;

int digt(int n)
{
    if (n == 0)
    {
        return 1;
    }

    int count = 0;
    while (n != 0)
    {
        n /= 10;
        count++;
    }
    return count;
}
void function(int n)
{
    for (int i = 0; i <= n; i++)
    {
        int temp = digt(i);
        if (i % 6 == 0)
        {
            cout << i << " ";
        }
        else
        {
            int num = i;
            for (int j = 0; j < temp; j++)
            {
                if (num % 10 == 6)
                {
                    cout << i << " ";
                    break;
                }else{
                    num /= 10;
                }
            }
        }
    }
    return;
}

int main()
{
    function(100);
}